package otg3.aspect;

import org.aopalliance.intercept.Joinpoint;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class SecuritAspect {
    @Pointcut("excution(* springaop3..addUser*(..))")
    public void addUserPointCut(){}

    @Pointcut("excution(* springaop3..deleteUser*(..))")
    public void deletePointCut(){}

    @Pointcut("excution(* springaop3..updateUser*(..))")
    public void updatePointCut(){}

    @Before("addUserPointCut() || deletePointCut() || updatePointCut()")
    public void beforeOperate(Joinpoint joinpoint){
        System.out.println(getTime()+"XX正在执行"+joinpoint.getSignature().getName()+"方法");
    }

    public String getTime(){
        LocalDateTime currentTime = LocalDateTime.now();

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        return currentTime.format(formatter);
    }

}
